$(function(){
	$("#login").click(function(){
		var username=$("#username").val();
		var password=$("#password").val();
		var code=$("#code").val();
		console.log(username);
		if(isNull(username)){
			alert("用户名不能为空");
			return;
		}
		if(isNull(password)){
			alert("用户名不能为空");
			return;
		}
		if(isNull(code)){
			alert("验证码");
			return;
		}
		$.ajax({
			url:'login',
			type:'post',
			dateType:'json',
			data:{username:username,password:password,code:code},
			success:function(data){
				if(data.status==0){
					window.location.href="index.html";
				}else{
					alert(data.msg);
				}
			},
			error:function(data){
				alert(errMsg);
			}
		})
	})
	
})

function changeImg(){
	var imgSrc = $("#codeImg");  
    var src = imgSrc.attr("src");
    var abc=changeUrl(src);
    imgSrc.attr("src", abc);
}

function changeUrl(url) {  
    var timestamp = (new Date()).valueOf();  
    var index = url.indexOf("?",url);  
    if (index > 0) {  
        url = url.substring(0, url.indexOf("?"));  
    }
    url = url + "?timestamp=" + timestamp;  
    return url;  
}  